#include <SimulationScene/Environment.h>

#include <string>
#include <QDir>
#include <QString>
#include <QDebug>
#include <iostream>
using namespace SimulationCore::SimulationScene;
void Environment::RegisterMap2DAll()
{
    std::string projPath = "";
#if _WIN32
	// set proj environment
	std::string scThridDir = std::getenv("SC_THIRD_DIR");
	projPath = scThridDir + "/share/proj";
	if (scThridDir.empty())
	{
		projPath = (QDir::currentPath() + QString("/share/proj")).toStdString();
	}
	_putenv_s("PROJ_LIB", projPath.c_str());
#else
    char* scThridDir = std::getenv("SC_THIRD_DIR");
    if (scThridDir && std::strlen(scThridDir) > 0) {
        projPath = std::string(scThridDir) + "/share/proj";
    } else {
        projPath = (QDir::currentPath() + QString("/share/proj")).toStdString();
    }
    
    setenv("PROJ_LIB", projPath.c_str(), 1);
#endif
}